class Solution(object):
    def maxProfit(self, prices):
        profits = [0]
        for i in range(1, len(prices)):
            profits.append(prices[i] - prices[i-1])

        largest = 0
        b = 0
        for i in profits:
            if b > 0:
                b += i
            else:
                b = i
            if b > largest:
                largest = b
        return largest

if __name__ == '__main__':
    s = Solution()
    r = s.maxProfit([7, 1, 5, 3, 6, 4])
    print(r)